package cn.dengta.webapp.trade.entity.meta;

import java.util.*;

import cn.dengta.context.model.WesKit;
import lombok.Getter;
import lombok.Setter;
import me.codeplayer.util.X;

/**
 * 国内首充礼包
 */
@Getter
@Setter
public class FirstPayInterBag implements MetaConfig.MetaRuleConfig {
	/** 充值礼包 */
	protected Map<WesKit, WesKitProduct> payBag;

	@Override
	public void validate() {

	}

	@Override
	public void init(MetaConfig.MetaRuleConfig config) {
		FirstPayInterBag bag = (FirstPayInterBag) config;
		this.payBag = bag.payBag;
	}

	public Set<Long> findProductIds() {
		if (X.isValid(payBag)) {
			Set<Long> ids = new HashSet<>(payBag.size() * 2, 1);
			payBag.forEach((k, v) -> {
				if (X.isValid(v.ipId)) {
					ids.add(v.ipId);
				}
				if (X.isValid(v.apId)) {
					ids.add(v.apId);
				}
			});
			return ids;
		}
		return Collections.emptySet();
	}

	@Getter
	@Setter
	public static final class WesKitProduct {

		/** 充值钻石数 */
		public Integer pc;
		/** 赠送钻石数 */
		public Integer fc;
		/** 礼物id */
		public Long gi;
		/** 礼物数量 */
		public Integer gn;
		/** 宣传图 */
		public String icon;
		/** 安卓 productId */
		public Long apId;
		/** ios productId */
		public Long ipId;

	}

}
